package com.example.administrator.shzs.db;
import android.content.Context;

import java.util.List;

/**
 * 接口视实现类实现增删改查
 */
public class OperateGoodsDataBase implements GoodsDataBaseInterface{

    private static OperateGoodsDataBase instance  = new OperateGoodsDataBase();

    public static OperateGoodsDataBase getInstance(){
        return  instance;
    }

    private OperateGoodsDataBase(){

    }


    /**
     *添加和删除商品数量,并得到商品数量
     */
    @Override
    public int saveGoodsNumber(Context context, int shopid, int goodsid,String goodsname ,String goodsnum , String goodsprice,String userid) {
        return OperateGoodsDataBaseStatic.saveGoodsNumber(context , shopid , goodsid ,goodsname, goodsnum ,goodsprice,userid);
    }
    /**
     *根据商家Id和商品Id购物的数量
     */
    @Override
    public int getGoodsNumber(Context context, int shopid, int goodsid) {
        return OperateGoodsDataBaseStatic.getGoodsNumber(context, shopid, goodsid);
    }
    /**
     * 根据shopId所有购物数量
     */
    @Override
    public int getGoodsNumberAll(Context context, int shopid) {
        return OperateGoodsDataBaseStatic.getGoodsNumberAll(context, shopid);
    }

    /**
     *据shopId所有购物的价格
     */
    @Override
    public double getGoodsPriceAll(Context context, int shopid) {
        return OperateGoodsDataBaseStatic.getGoodsPriceAll(context, shopid);
    }

    /**
     * 删除单条数据
     * @param context
     * @param num 商品数量
     * @param goodsid 商品Id
     */
    @Override
    public void deleteSingle(Context context, String num, int goodsid) {
        OperateGoodsDataBaseStatic.deleteSingle(context,num,goodsid);
    }

    /**
     *删除所有的商家购物数据<<清空数据库>>
     */
    @Override
    public void deleteAll(Context context) {
        OperateGoodsDataBaseStatic.deleteAll(context);
    }

    /**
     * 根据商家shopId获取购物车中所有商品数据
     * @param context
     * @param shopid 商家Id
     * @return
     */
    public List<GoodsBean> getGoodsCarData(Context context, int shopid){
       return OperateGoodsDataBaseStatic.getGoodsCarData(context,shopid);
    }
}
